package mypack;

import java.io.IOException;

import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;

@SuppressWarnings("deprecation")
public class MyDriver extends Configured implements Tool
{
	
	public int run(String [] args) throws IOException, Exception
	{
		long start = System.currentTimeMillis();
		Manager.CreateInitialPopulation();
		
		int iterationNumber = 0;
		while (iterationNumber < Global.MAX_ITERATION_NUMBER && !Manager.isGoodEnough(iterationNumber) ) 
		{
			iterationNumber++;
			System.out.println("iteration number: "+iterationNumber);
			Manager.evolveOneStep();
		}

		Manager.finishEvolution();
		long timeElapsed = System.currentTimeMillis() - start;
		float timeInSecond = timeElapsed / (float)1000.0;
		System.out.println("Time elapsed in second : "+timeInSecond);
		return 0;
	}
	
	public static void main(String [] args) throws Exception 
  	{
		try
		{	
			int ret = ToolRunner.run(new MyDriver(), args);
		    System.exit(ret);	
		
		} catch (Exception e) 
		{
			System.out.println("sistemde hata");
		}
 	} 

//	public static void main(String[] args)  throws Exception 
//	{	
//		Manager.CreateInitialPopulation();
//		int iterationNumber = 0;
//		while (iterationNumber < Global.MAX_ITERATION_NUMBER && !Manager.isGoodEnough(iterationNumber)) 
//		{
//			iterationNumber++;
//			System.out.println("iteration number: "+iterationNumber);
//			Manager.evolveOneStep();
//		}
//		
//		Manager.finishEvolution();
//			
//	}

}
